import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

// 首页
import Home from "@/pages/home"

const Login = resolve => require(['@/pages/login'], resolve);

const NotFound = resolve => require(['@/pages/404'], resolve);

// 部门&联系人列表页
const List = resolve => require(['@/pages/list'], resolve);

// 联系人新增/编辑页
const ContactAdd = resolve => require(['@/pages/contact_add'], resolve);
const ContactLocalAdd = resolve => require(['@/pages/contact_local_add'], resolve);
const ContactEdit = resolve => require(['@/pages/contact_edit'], resolve);
const ContactDel = resolve => require(['@/pages/contact_del'], resolve);


// 部门新增/编辑也
const Department = resolve => require(['@/pages/department'], resolve);

// 部门选择页
const DepartmentSeletor = resolve => require(['@/pages/department_seletor'], resolve);

const ContactLevelSeletor = resolve => require(['@/pages/contactLevel_seletor'], resolve);

const PermissionLimit = resolve => require(['@/pages/permission_limit'], resolve);

// export new Router
export default new Router({
  	routes: [
  		{ 
  			path: '*', 
  			component: NotFound 
  		},
  		{
  			path: '/login',
  			name: 'login',
  			component: Login
  		},
	    {
	      	path: '/',
	      	redirect: to => {
	      		return '/list/0';
		    }
	    },
	    {
	    	path: '/home',
	    	name: 'home',
			component: Home
	    },
	    {
	    	path: '/list/:departmentId',
	    	name: 'list',
	    	component: List
	    },
	    {
	    	path: '/contact/add/:departmentId',
	    	name: 'contact_add',
	    	component: ContactAdd
	    },
	    {
	    	path: '/contact/local/add/:departmentId',
	    	name: 'contact_local_add',
	    	component: ContactLocalAdd
	    },
	    {
	    	path: '/contact/eidt/:departmentId/:id',
	    	name: 'contact_edit',
	    	component: ContactEdit
	    },
	    {
	    	path: '/contact/del/:departmentId',
	    	name: 'contact_del',
	    	component: ContactDel
	    },
	    {
	    	path: '/department/add/:parentId',
	    	name: 'department_add',
	    	component: Department
	    },
	    {
			path: '/department/edit/:id',
			name: 'department_edit',
			component: Department
		},
		{
			path: '/department/seletor',
			name: 'department_seletor',
			component: DepartmentSeletor
		},
		{
			path: '/contactlevel/seletor',
			name: 'contactLevel_seletor',
			component: ContactLevelSeletor
		},
		{
			path: '/permission/limit',
			name: 'permission_limit',
			component: PermissionLimit
		}

  	]
})


